<?php

namespace App\Observers;

use App\Models\CouponRecord;

class CouponRecordObserver
{
	public function creating(CouponRecord $couponRecord)
	{
		if (! $couponRecord->code) {
			$couponRecord->code = serial_number(4, $couponRecord, 'code');
			
			if (! $couponRecord->code) {
				return false; // Order is failed.
			}
		}
	}
}
